<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class ExaminationRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'category_id' => 'required|exists:categories,id,category_group_id,2',
            'name' => 'required|min:2|max:32',
            'subject_id' => 'required|exists:categories,id,category_group_id,1',
            'type' => 'sometimes|in:1,2,3',
            'examination_mode' => 'sometimes|boolean',
            'start_time' => 'required|date',
            'over_time' => 'required|date|after:today',
            'timer' => 'required|integer',
            'peoples' => 'array|exists:users,id',
            'show_result' => 'sometimes|boolean',
            'show_answer' => 'sometimes|boolean',
            'mouse_out' => 'sometimes|boolean',
            'mouse_out_num' => 'sometimes|min:0|max:100|integer',
            'test_list_id' => 'required|exists:test_lists,id'
        ];

    }

    public function attributes()
    {
        return [
            'category_id' => '分类',
            'subject_id' => '科目',
            'name' => '考试名称',
            'start_time' => '开考时间',
            'over_time' => '截至进入考场时间',
            'timer' => '考试时长',
            'peoples' => '考试人',
            'type' => '考试类型',
            'examination_mode' => '考试模式',
            'show_result' => '允许查看成绩',
            'show_answer' => '允许查看答案',
            'mouse_out' => '鼠标移出自动交卷',
            'mouse_out_num' => '鼠标移出次数',
            'test_list_id' => '试卷id',
        ];
    }
}

